<style lang='less'>
</style>

<template>
  <div>
    <Row>
      <Col span="4" align="center">
        <RadioGroup v-model="params.type" type="button">
          <Radio label="0">成人</Radio>
          <Radio label="1">儿童</Radio>
        </RadioGroup>
      </Col>
      <Col span="4" align="center">
        <Input placeholder="实体码数量" v-model="params.count" style="width: 94%"/>
      </Col>
      <!--    <Col span="4" align="center">-->
      <!--      <Input placeholder="起始编号" v-model="start_code" style="width: 94%"/>-->
      <!--    </Col>-->
      <!--    <Col span="4" align="center">-->
      <!--      <Input placeholder="结束编号" v-model="end_code" style="width: 94%"/>-->
      <!--    </Col>-->
      <Col span="4" align="center">
        <Button icon="ios-print" style="color:#1874CD" @click="print()">打印</Button>
      </Col>
    </Row>
    <div ref="qrcode"></div>
  </div>
</template>

<script>
import { getSstWlmCord } from '@/api/print'
import { getLodop } from '../components/LodopFuncs'

export default {
  components: {},
  data () {
    return {
      dataList: [],
      params: {
        count: 1,
        type: '0'
      }
    }
  },
  watch: {},
  methods: {
    print () {
      if (this.params.count === undefined) {
        this.$Modal.error({
          title: '错误',
          content: '实体码数量为空',
          onOk: () => {
          }
        })
        return
      }
      getSstWlmCord(this.params).then(ret => {
        if (ret.data.errcode === 0) {
          let LODOP = getLodop()
          // var qr = require('qr-image')
          LODOP.PRINT_INITA(3, 5, 800, 600, '')
          LODOP.SET_PRINT_PAGESIZE(1, 400, 300, '')
          ret.data.data.list.forEach(function (temp) {
            LODOP.NewPage()
            // LODOP.ADD_PRINT_TEXT(9, 17, 110, 20, temp)
            // LODOP.SET_PRINT_STYLEA(0, 'FontSize', 12)
            // var qr_svg = qr.imageSync(temp, { type: 'svg' })
            // // console.log(qr_svg)
            // // console.log('-----------------')
            // let base64 = Buffer.from(qr_svg).toString('base64')
            // console.log(base64)
            // LODOP.ADD_PRINT_IMAGE(100, 100, '100%', '100%', base64)
            LODOP.ADD_PRINT_BARCODE(-5, 10, '33mm', '33mm', 'QRCode', temp)
          })
          // LODOP.PREVIEW();
          LODOP.PRINT_DESIGN()
        } else {
          this.$Notice.error({
            title: '失败',
            desc: ret.data.errmsg
          })
        }
      })
      // let LODOP = getLodop()
      // LODOP.PRINT_INITA(3, 5, 800, 600, '')
      // LODOP.SET_PRINT_PAGESIZE(1, 400, 300, '')
      // var list = ['SY0001YP0001', 'SY0001YP0002', 'SY0001YP0003']
      // for (var i = 0; i < list.length; i++) {
      //   LODOP.NewPage()
      //   LODOP.ADD_PRINT_TEXT(9, 17, 110, 20, list[i])
      //   LODOP.SET_PRINT_STYLEA(0, 'FontSize', 12)
      // }
      // // LODOP.PREVIEW();
      // LODOP.PRINT_DESIGN()
    }
  },
  mounted () {

  }
}
</script>

<style>

</style>
